package com.qf.service.impl;

import com.qf.dao.SWanInfoDao;
import com.qf.dao.SWanInfoRespository;
import com.qf.pojo.SWanInfo;
import com.qf.service.SWanInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class SWanInfoServiceImpl implements SWanInfoService {
    @Autowired
    SWanInfoRespository sWanInfoRespository;
    @Autowired
    SWanInfoDao sWanInfoDao;
    @Override
    public List<SWanInfo> findAll() {
        return sWanInfoRespository.findAll();
    }

    @Override
    public SWanInfo findById(Integer id) {
        Optional<SWanInfo> byId = sWanInfoRespository.findById(id);
        return byId.get();
    }

    @Override
    public void deleteById(Integer id) {
        sWanInfoRespository.deleteById(id);

    }

    @Override
    public void saveAndUpdate(SWanInfo sWanInfo) {
        sWanInfoRespository.saveAndFlush(sWanInfo);

    }

    @Override
    public List<SWanInfo> findMusicBySSexAndSCountry(Integer ssex, String scountry) {
        return  sWanInfoDao.findMusicBySSexAndSCountry(ssex,scountry);
    }

    @Override
    public List<SWanInfo> findMusicBySTypeAndSCountry(Integer stype,String scountry) {
        return sWanInfoDao.findMusicBySTypeAndSCountry(stype,scountry);
    }
}
